<template>
  <div id="wuzhou" :class="{ h5: this.$store.state.webType === 'h5' }">
    <!--    <el-row :span="24" class="page">-->
    <!--      &lt;!&ndash; 面包屑 &ndash;&gt;-->
    <!--      <el-breadcrumb separator-class="el-icon-arrow-right">-->
    <!--        <el-breadcrumb-item :to="{ path: '/' }">{{-->
    <!--            $t('home')-->
    <!--          }}-->
    <!--        </el-breadcrumb-item>-->
    <!--        <el-breadcrumb-item>{{ $t('sections') }}</el-breadcrumb-item>-->
    <!--        <el-breadcrumb-item>{{ $t('travel') }}</el-breadcrumb-item>-->
    <!--      </el-breadcrumb>-->
    <!--    </el-row>-->
    <div class="banner-view">
      <div class="members_banner_img">
        <img
          src="https://lanhu-dds-backend.oss-cn-beijing.aliyuncs.com/merge_image/imgs/0bfff65c32db4c1882f26559439cb591_mergeImage.png"
        />
      </div>
      <div class="members_banner_box">
        <div class="members_banner_title">Membership</div>
        <div class="members_banner_content">
          A UNESCO Clubs,Centres;and
          Associations,(having&nbsp;minimum&nbsp;three&nbsp;UNESCO&nbsp;Clubs,&nbsp;Centres&nbsp;and&nbsp;Associations&nbsp;in&nbsp;that&nbsp;country&nbsp;as&nbsp;members)&nbsp;with&nbsp;recommendation&nbsp;of&nbsp;the&nbsp;National&nbsp;Commission&nbsp;for&nbsp;UNESCO&nbsp;of&nbsp;that&nbsp;country&nbsp;can&nbsp;apply&nbsp;for&nbsp;the&nbsp;membership&nbsp;of&nbsp;WFUCA.&nbsp;The&nbsp;membership&nbsp;is&nbsp;approved&nbsp;by&nbsp;the&nbsp;World&nbsp;Congress&nbsp;of&nbsp;WFUCA&nbsp;on&nbsp;recommendation&nbsp;of&nbsp;its&nbsp;Executive&nbsp;Board.
        </div>
      </div>
      <!-- <el-carousel trigger="click" :arrow="'always'" :height="bannerHeight + 'px'">
        <el-carousel-item v-for="(item, index) in bannerData" :key="index">
          <div
            class="banner-item"
            @click="$goDetail(item.id)"
            :style="{
              height: '100%',
              background: `url('${item.imgUrl}') no-repeat  center`,
              backgroundSize: 'cover',
            }"
          >
            <div class="item-title" @click="$goDetail(item.id)">
              {{ item.title }}
            </div>
          </div>
        </el-carousel-item>
      </el-carousel> -->
    </div>

    <div class="page-content">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="Join-in Process" name="first">用户管理</el-tab-pane>
        <el-tab-pane label="Countries with Clubs and Associations for UNESCO" name="second">
          <div class="form_search_box">
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
              <el-form-item label="name">
                <el-input v-model="formInline.user" placeholder="审批人"></el-input>
              </el-form-item>
              <el-form-item label="country">
                <el-select v-model="formInline.region" placeholder="活动区域">
                  <el-option label="区域一" value="shanghai"></el-option>
                  <el-option label="区域二" value="beijing"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="belong to">
                <el-select v-model="formInline.region" placeholder="活动区域">
                  <el-option label="区域一" value="shanghai"></el-option>
                  <el-option label="区域二" value="beijing"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="onSubmit">search</el-button>
              </el-form-item>
            </el-form>
          </div>
          <div class="form_table_box">
            <el-table :data="tableData" style="width: 100%">
              <el-table-column type="index" label="No."> </el-table-column>
              <el-table-column prop="address" label="Name"> </el-table-column>
              <el-table-column prop="name" label="Country" width="180"> </el-table-column>
              <el-table-column prop="name" label="Belong to" width="180"> </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import HotArticle from "@/components/HotArticle";
import NewBook from "@/components/NewBook";
import goTop from "../components/goTop";

export default {
  name: "CharacterStory",
  components: {
    goTop,
    HotArticle,
    NewBook,
  },
  data() {
    return {
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
          zip: 200333,
          tag: "家",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1517 弄",
          zip: 200333,
          tag: "公司",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1519 弄",
          zip: 200333,
          tag: "家",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1516 弄",
          zip: 200333,
          tag: "公司",
        },
      ],
      formInline: {
        user: "",
        region: "",
      },
      activeName: "second",
      busy: true,
      nomore: false,
      gutterWidth: 20,
      bannerHeight: 0, // 轮播图容器高度;
      currentView: "img",
      bannerData: [],
      bookData: {},
      articleData: [],
      artData: [],
      // 文章总数量
      listTotal: 0,
      maxPage: 1,
      // 文章列表请求信息
      listQuery: {
        columnId: "",
        labelId: "",
        pageSize: 10,
        pageNum: 1,
      },
      // 标签
      labelData: [],
      currentLabel: "",
      imgCount: 0,
    };
  },
  mounted() {
    this.screenWidth = window.innerWidth;
    this.bannerHeight = (860 / 1920) * this.screenWidth;
    console.log("bannerHeight", this.bannerHeight);
    if (this.$store.state.webType === "h5") {
      this.bannerHeight += 42;
    }
    // 窗口大小发生改变
    window.onresize = () => {
      this.screenWidth = window.innerWidth;
      this.bannerHeight = (860 / 1920) * this.screenWidth;
      if (this.$store.state.webType === "h5") {
        this.bannerHeight += 42;
      }
    };

    if (this.$route.query.token) {
      sessionStorage.setItem("token", this.$route.query.token);
    }
    this.listQuery.columnId = this.$getPartId(this.$route.path);
    this.listQuery.menuId = this.$getMenuId(this.$route.path);
    this.listTotal = 0;
    this.maxPage = 1;
    this.getList();
    this.getBanner();
    this.getLabels();
  },
  methods: {
    indexMethod(index) {
      return index * 2;
    },
    onSubmit() {
      console.log("submit!");
    },
    viewTypeChange(type) {
      this.currentView = type;
    },
    async loadMore() {
      // console.log(
      //   "loadMore",
      //   this.busy || this.listQuery.pageNum >= this.maxPage
      // );
      if (this.busy || this.listQuery.pageNum >= this.maxPage) return;
      this.busy = true;
      this.listQuery.pageNum += 1;
      await this.getList();
    },
    async getList() {
      // 如果是重新获取 imgCount计0
      if (this.artData.length == 0) {
        this.imgCount = 0;
      }
      this.$get(`${this.$api}/cms/web/selsctWeb`, this.listQuery).then((res) => {
        const { data } = res;
        let list = []; // 小图list
        let listMax = []; // 大图list
        let listEnd = []; // 拼凑完成的最终list
        let num = 0;
        if (this.$store.state.webType === "h5") {
          num = 4;
        } else {
          num = 3;
        }
        list = data.filter((item) => item.imgIsMax !== "Y");
        listMax = data.filter((item) => item.imgIsMax === "Y");
        //  console.log(list, listMax);
        list.forEach((item, index) => {
          if (index != 0 && this.imgCount % num == 0) {
            // console.log(index);
            // 如果每轮加载完第一行了  大图list加入 最终list
            listEnd = [...listEnd, ...listMax];
            // 大图list置空
            listMax = [];
            listEnd.push(item);
          } else {
            listEnd.push(item);
          }
          this.imgCount += 1;
        });
        // 如果没满足加载完一行（小图数量不足）  大图list加入 最终list
        if (listMax.length > 0) {
          listEnd = [...listEnd, ...listMax];
        }
        this.artData = [...this.artData, ...listEnd];
        this.listTotal = res.total;
        this.maxPage = res.maxPage;

        const that = this;
        this.$nextTick(() => {
          that.nomore = true;
          setTimeout(() => {
            that.busy = false;
          }, 300);
        });
      });
    },
    changeLabel(id, label) {
      this.listQuery.labelId = id;
      this.listQuery.pageNum = 1;
      this.currentLabel = label;
      this.artData = [];
      this.getList();
    },
    getLabels() {
      this.$get(`${this.$api}/cms/web/getLabelByPartId`, {
        partId: this.listQuery.columnId,
      }).then((res) => {
        this.labelData = res.data;
      });
    },
    getListMore() {
      this.listQuery.pageNum += 1;
      this.getList();
    },
    getBanner() {
      this.$get(`${this.$api}/cms/web/partArticleBanner`, {
        menuId: this.listQuery.menuId,
      }).then((res) => {
        this.bannerData = res.data;
        console.log(res.data);
        // res.data.forEach((item) => {
        //   this.bannerData.push(item);
        // });
      });
    },
  },
};
</script>
<style>
/*// 不现实背景图*/
body,
html {
  position: relative;
  z-index: -2;
}
</style>

<style lang="scss" scoped>
.en #wuzhou > .page::after {
  background: url("../assets/images/wzyy-bg-en.jpg") no-repeat !important;
}

#wuzhou {
  position: relative;
  width: 100%;

  > .page {
    padding: fh(152vh, pc) fw(80vw, pc) fh(20vh, pc) fw(80vw, pc);
    background: linear-gradient(180deg, rgba(2, 21, 91, 0.1) 0%, rgba(1, 8, 35, 0.3) 100%);

    &::after {
      //content: "";
      position: absolute;
      left: 0;
      top: 0;
      z-index: -1;
      width: 100%;
      height: 100%;
      //background: url('../assets/images/wzyy-bg.jpg') no-repeat !important;
      background-size: cover;
      background-position: center 0;
    }

    ::v-deep .el-breadcrumb {
      // margin-left: fw(-40vw, pc);
      .el-breadcrumb__inner {
        font-weight: bold;
        color: #fff !important;
        font-size: fh(18vh, pc);
      }
    }
  }

  .page-content {
    margin: 0 auto;
    margin-top: 27px;
    width: 77%;
  }

  .banner-view {
    width: 100%;
    .members_banner_img {
      margin: 0 auto;
      width: 78%;
    }
    .members_banner_box {
      margin: 0 auto;
      width: 78%;
      padding: 15px;
      .members_banner_title {
        overflow-wrap: break-word;
        color: rgba(0, 93, 176, 1);
        font-size: 32px;
        font-family: "SourceHanSansCN-Medium";
        font-weight: 500;
        text-align: left;
        white-space: nowrap;
        line-height: 48px;
      }
      .members_banner_content {
        overflow-wrap: break-word;
        color: rgba(42, 42, 42, 1);
        font-size: 16px;
        font-family: "SourceHanSansCN-Regular";
        font-weight: normal;
        text-align: left;
        line-height: 24px;
      }
    }
    ::v-deep .el-carousel__indicators {
      bottom: fh(32vh, pc);
      .el-carousel__button {
        width: 40px;
        height: 4px;
        border-radius: 2px;
      }
    }
    .banner-item {
      position: relative;
      cursor: pointer;
      box-shadow: 10px -200px 500px 10px rgba(9, 9, 9, 0.2) inset;

      .item-title {
        position: absolute;
        width: 100%;
        padding: fh(20vh, pc) fw(80vw, pc);
        left: 0;
        bottom: fh(80vh, pc);
        color: #fbfeff;
        font-size: fh(36vh, pc);

        .text {
          position: absolute;
          bottom: fh(20vh, pc);
          height: fh(50vh, pc);
          overflow: hidden;
        }

        &:hover {
          opacity: 0.8;
        }
      }

      .video-icon {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: fw(46vw, pc);
        background-color: #fff;
        border-radius: 90%;

        &:hover {
          opacity: 0.8;
        }
      }
    }
  }

  .banner-view-none {
    min-height: fh(700vh, pc);
  }

  .art-row {
    display: flex;
    padding-top: fh(28vh, pc);
    width: 100%;

    .book-content {
      background-color: $fh90;
      padding-bottom: fh(40vh, pc);

      .book-btn {
        display: flex;
        width: 100%;
        align-items: flex-end;
        justify-content: center;

        img {
          width: fw(180vw, pc);

          &:hover {
            cursor: pointer;
            opacity: 0.7;
          }
        }
      }

      .book-row {
        display: flex;
        width: 100%;
        padding: fh(46vh, pc) fw(20vw, pc);
        color: $sh;

        img.book-img {
          width: fw(280vw, pc);
        }

        .book-text {
          padding-left: fw(10vw, pc);

          .view-label {
            color: $zh;
            position: relative;
            display: inline-block;
            font-size: fh(24vh, pc);
            font-weight: 800;
            margin-top: fh(20vh, pc);
            margin-bottom: fh(60vh, pc);

            &::after {
              content: "";
              position: absolute;
              bottom: fh(-16vh, pc);
              right: fw(-12vw, pc);
              width: fw(30vw, pc);
              height: fh(18vh, pc);
              border-right: fw(6vw, pc) solid hsla(14, 74%, 37%, 0.2);
              border-bottom: fw(8vw, pc) solid hsla(14, 74%, 37%, 0.2);
            }
          }

          .text-item {
            padding-bottom: fh(30vh, pc);

            .item-title {
              color: $sh;
              font-size: fh(18vh, pc);
              font-weight: bold;
              padding-bottom: fh(20vh, pc);
            }

            .item-content {
              font-size: fh(16vh, pc);
              line-height: fh(26vh, pc);
            }
          }
        }
      }
    }

    .row-right {
      display: flex;
      flex: 1;
      margin-left: fw(20vw, pc);
      flex-flow: column;

      .hot-article {
        width: 100%;
        padding: fh(30vh, pc) fw(30vw, pc);
        background-color: $fh90;
        margin-top: 0;

        .article-label {
          color: $zh;
          position: relative;
          display: inline-block;
          font-size: fh(24vh, pc);
          font-weight: 800;
          margin-top: fh(20vh, pc);
          margin-bottom: fh(60vh, pc);

          &::after {
            content: "";
            position: absolute;
            bottom: fh(-16vh, pc);
            right: fw(-12vw, pc);
            width: fw(30vw, pc);
            height: fh(18vh, pc);
            border-right: fw(6vw, pc) solid hsla(14, 74%, 37%, 0.2);
            border-bottom: fw(8vw, pc) solid hsla(14, 74%, 37%, 0.2);
          }
        }

        .article-view {
          color: $sh;

          .article-item {
            width: fw(485vw, pc);
            line-height: fh(26vh, pc);
            margin-bottom: fh(26vh, pc);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;

            span {
              color: $zh;
              font-size: fh(18vh, pc);
              font-weight: bold;
              display: inline-block;
              padding-right: fw(16vw, pc);
            }

            &:hover {
              opacity: 0.8;
              cursor: pointer;
              color: $zh;
            }
          }
        }
      }
    }
  }

  .art-col {
    position: relative;
    width: fw(1180vw, pc);
    margin-top: fh(46vh, pc);

    .art-tab {
      width: 100%;
      display: flex;
      align-items: center;
      margin-bottom: fh(30vh, pc);
      color: $sh;

      .tab-item {
        margin-right: fw(60vw, pc);
        font-size: fh(16vh, pc);
        position: relative;
        line-height: fh(24vh, pc);

        &:hover {
          color: $sh;
          cursor: pointer;
        }

        &.active {
          font-size: fh(20vh, pc);
          font-weight: bold;
          color: $sh;

          &::before {
            content: "";
            position: absolute;
            bottom: fh(-14vh, pc);
            width: 100%;
            border-top: fh(6vh, pc) solid $zh;
          }
        }
      }

      .tab-info {
        margin-left: auto;
        display: flex;
        align-items: center;

        .toggle-img {
          margin-left: fh(62vw, pc);
          margin-right: fh(24vw, pc);
        }

        img {
          width: fw(20vw, pc);
          cursor: pointer;
        }
      }
    }

    .art-view {
      position: relative;
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;

      &.text {
        .art-item {
          width: 100%;
        }

        .item-title {
          color: $sh;
          display: flex;
          width: 100%;

          .item-info {
            padding-left: fw(40vw, pc);
            margin-left: auto;
            width: max-content !important;

            .info-label {
              margin-right: fw(20vw, pc);
              width: max-content !important;
            }

            .info-time {
              width: max-content;
              margin-left: fw(20vw, pc) !important;
            }
          }
        }
      }

      .art-item {
        width: calc((100% - 40px) / 3);
        margin-bottom: fh(20vh, pc);
        background-color: $dh;
        cursor: pointer;

        &.big {
          width: 100%;
        }

        img {
          width: 100%;
        }

        .art-content {
          position: relative;
          z-index: 2;
          background-color: $dh;
          width: 100%;
          color: rgba(251, 254, 255, 0.8);
          padding: fh(20vh, pc) fw(20vw, pc);

          .item-title {
            color: $sh;
            font-size: fh(16vh, pc);
            line-height: fh(26vh, pc);
            margin-bottom: fh(8vh, pc);
            font-weight: 600;
            color: $sh;
            height: fh(52vh, pc);
            overflow: hidden;
          }

          .item-info {
            margin-left: auto;
            display: flex;
            align-items: center;
            width: 100%;
            justify-content: space-between;
            font-size: fh(14vh, pc);
            line-height: fh(20vh, pc);

            .info-time {
              color: #a1b8bd;
              margin-left: auto;
            }
          }

          .item-content {
            font-size: fh(14vh, pc);
            line-height: fh(20vh, pc);
            font-weight: 400;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }

    .art-more {
      width: max-content;
      margin: fh(40vh, pc) auto;
      color: $sh;
      font-size: fh(14vh, pc);

      &.true:hover {
        cursor: pointer;
        opacity: 0.8;
        color: $zh;
      }

      &.none {
        opacity: 0.5;
      }
    }
  }
}

#wuzhou.h5 {
  &::after {
    background-size: cover !important;
  }
  ::v-deep .banner-view {
    .el-carousel__indicators.el-carousel__indicators--horizontal {
      bottom: 1px !important;
      .el-carousel__button {
        width: 28px;
        height: 2px;
        border-radius: 2px;
      }
    }
    .el-carousel__arrow {
      background-color: rgba(255, 255, 255, 0);
      transform: translateY(10%);

      &.el-carousel__arrow--left {
        left: -10px;
      }
      &.el-carousel__arrow--right {
        right: -10px;
      }
    }
    .item-title {
      font-size: fh(16vh, h5);
      line-height: fh(22vh, h5);
      // top: 20px;
      top: 156px;
    }
  }
  .art-col {
    .art-view {
      padding-bottom: fh(0vh, h5);

      .art-item {
        width: calc(50% - 10px);

        &.big {
          width: 100%;
        }
      }

      &.text {
        .art-item {
          width: 100%;
        }

        .art-item {
          .art-content {
            padding: fw(8vw, h5) !important;
          }
        }
      }
    }
  }

  .banner-view-none {
    display: none !important;
  }

  .banner-view {
    padding-top: fh(10vh, h5);
    width: 100%;

    .banner-title {
      font-size: fh(20vh, h5);
    }

    .banner-content {
      margin-top: fh(6vh, h5);
    }

    .banner-row {
      flex-wrap: wrap;

      .banner-item {
        width: 49%;
        margin-bottom: fh(10vh, h5);

        img {
          width: 100%;
        }

        .item-title {
          // color: $sh;
          font-size: fh(12vh, h5);
          line-height: fh(16vh, h5);
          height: fh(48vh, h5);
          padding: fh(8vh, h5) fw(4vw, h5);
        }
      }
    }
  }
}
</style>
